<?php defined('SEJUJOPEFDNGJSL') or exit('Access denied');?>
<div class="">
	<div class="indent-r-kuai-image clear">
		<div class="row">
			<div class="col-md-6">
				<span class="kuai-im im4"><a href="<?php echo SITEINDEX?>?lsact=cunkuan"><img src="theme/images/setbg.png">提供帮助</a></span>
			</div>
			<div class="col-md-6">
				<span class="kuai-im im5" style="margin-right: 0px;"><a href="<?php echo SITEINDEX?>?lsact=qukuan"><img src="theme/images/getbg.png">获取帮助</a></span>
			</div>
	    </div>
	</div>
	<div class="panel panel-inverse">
        <div class="panel-heading">
            <h4 class="panel-title">见点奖明细</h4>
        </div>
        <div class="panel-body">
        	<div class="table-responsive">
	        	<table border="0" cellpadding="0" cellspacing="0" style="margin:0 auto;margin-top:20px;width:97%;" class="table table-bordered table-striped givetable" align="center" >
					  <tbody>
						<tr>
							<th>序号</th>
							<th>奖金类型</th>
							<th>金额</th>
							<th>交易时间</th>
							<th>所属订单号</th>
							<th>备注</th>
						</tr>
						<?php
							$xuhao=0;
							$db->query("select *,SUM(amount) as samount from (select * from ld_prize_list order by prize_ltime desc) as tmp where prize_option = 54 and lx_generation = 1 and uid = ".$_userid." group by help_id");
							$prize_list = $db->rs;
							$combine_arr = array();
							$tmparr = array();
							if(!empty($prize_list)){
								foreach($prize_list as $k=>$v){
									$give_help_info = give_get_help('give',$v['help_id'],'','');
									$tmparr['order_no'] = $give_help_info['give_help_no'];
									$give_helper = $member->getuv1($give_help_info['uid'],'is_freezed');
									if($give_help_info['status'] < 2 && empty($give_help_info['giveh_eviup_time']) && $give_helper['is_freezed'] == 0){
										$tmparr['amount'] = $v['samount'];
										$tmparr['timetime'] = date("Y-m-d H:i:s",$v['prize_ltime']);
										$tmparr['orderby'] = substr($tmparr['order_no'],-14);
										if(strstr($v['description'],"，")){
											$description = explode("，",$v['description']);
											$tmparr['description'] = $description[1];
										}else{
											$tmparr['description'] = '';
										}
										array_push($combine_arr,$tmparr);
										$tmparr = array();
									}
								}
							}
							foreach ($combine_arr as $ke=>$ve){
								$temparr[$ke] = $ve['orderby'];
							}
							array_multisort($temparr,SORT_NUMERIC,SORT_DESC,$combine_arr);
							?>
							<?php
							if(!empty($combine_arr)){
								foreach($combine_arr as $carr){
									$xuhao++;
							?>
								<tr>
									<td><?php echo $xuhao; ?></td>
									<td>见点奖（1代）</td>
									<td style="color:red;"><?php echo $carr['amount']; ?></td>
									<td><?php echo $carr['timetime']; ?></td>
									<td><a style="color:blue;" href="javascript:;" onclick="showfellow('<?php echo $carr['order_no']; ?>');"><?php echo "T".encorder($carr['orderby']); ?></a></td>
									<td><?php echo $carr['description']; ?></td>
								</tr>
							<?php
								}
							}
							?>
							<?php
							$db->query("select SUM(p.amount) as samount from ld_prize_list as p left join ld_give_help as c on p.help_id = c.id left join ld_user_account as a on c.uid = a.id where p.prize_option = 54 and p.lx_generation > 1 and p.prize_status = 0 and a.is_freezed = 0 and p.uid = ".$_userid,2);
							$jdtc = $db->rs;
							if(!empty($jdtc) && $jdtc['samount'] > 0){
								$xuhao++;
							?>
							<tr>
								<td><?php echo $xuhao; ?></td>
								<td>见点奖（2-3代）</td>
								<td><?php echo $jdtc['samount']; ?></td>
								<td></td>
								<td><a style="color:black;" href="javascript:;" onclick="showdj();">详细信息</a></td>
								<td></td>
							</tr>
							<?php
							}
							?>
					</tbody>
				</table>
			</div>

        </div>
    </div>
</div>
<div class="layer_fellow" style="display: none;">
	<div style="margin-top:20px;" id="helper_nick_name"></div>
	<div id="helper_account"></div>
	<div id="bill_amount"></div>
	<div id="contact_phone"></div>
</div>
<div class="djglj" style="display: none;">
	<div class="djgljframe">
		<table>
			<tbody>
				<tr><th width=150>昵称</th><th width=80>提供帮助金额</th><th width=120>订单编号</th><th width='80'>见点奖金额</th><th width=120>备注</th></tr>
	<?php
	$db->query("select *,SUM(amount) as samount from ld_prize_list where prize_option = 54 and lx_generation > 1 and uid = ".$_userid." and prize_status = 0 group by help_id");
	$prize_list = $db->rs;
	if(!empty($prize_list)){
		foreach($prize_list as $k=>$v){
			$the_give_help = give_get_help('give',$v['help_id'],'','');
			$order_no = $the_give_help['give_help_no'];
			$give_helper = $member->getuserinfo($the_give_help['uid']);
			if(strstr($v['description'],"，")){
				$description_arr = explode("，",$v['description']);
				$description_txt = $description[1];
			}else{
				$description_txt = '';
			}
			if($give_helper['is_freezed'] == 0){
	?>

			<tr>
				<td><?php echo $give_helper['nick_name']; ?></td>
				<td><?php echo $the_give_help['amount'] ?></td>
				<td><?php echo get_help_no("give",$the_give_help['uname'],$order_no); ?></td>
				<td><?php echo $v['samount']; ?></td>
				<td><?php echo !empty($description_txt) ? "（".$description_txt."）" : "" ?></td>
			</tr>
	<?php
			}
		}
	}
	?>
			</tbody>
		</table>
	</div>
</div>
<script type="text/javascript" src="theme/js/layer/layer.js"></script>
<script type="text/javascript">
	function showfellow(order_no){
		$.ajax({
			type: "post",
			url: "ajax.php?act=give_help_detail",
			dataType: "json",
			data:{"order_no":order_no},
			success: function(data){
				if (data.status) {
					$("#helper_nick_name").html("提供帮助人昵称："+data.nick_name);
					$("#helper_account").html("提供帮助人账号："+data.give_help_uname);
					$("#bill_amount").html("订单金额："+data.give_help_amount);
					$("#contact_phone").html("联系电话："+data.contact_phone);
				} else {
					alert(data.mes);
				}
			},
			error: function(){}
		});
		layer.open({
			type: 1,
			title: ['相关订单', 'font-size:14px;background-color:#b5c0c7;color:#fff;'],
			area: ['575px', '305px'],
			closeBtn: 1, //不显示关闭按钮
			shift: 2,
			shade:0,
			shadeClose: true, //开启遮罩关闭
			content: $('.layer_fellow')
		});
		return false;
	}
	function showdj(){
		layer.open({
			type: 1,
			title: ['见点奖（冻结）', 'font-size:14px;background-color:#b5c0c7;color:#fff;'],
			area: ['575px', '480px'],
			closeBtn: 1, //不显示关闭按钮
			shift: 2,
			shade:0,
			shadeClose: true, //开启遮罩关闭
			offset:['100px','10px'],
			scrollbar:true,
			content: $('.djglj')
		});
		return false;
	}
</script>